import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

import Index from '../view/Index.vue'
import Show from '../view/Show.vue'
import Goods from '../components/Goods.vue'
import Comments from '../components/Comments.vue'
import Store from '../components/Store.vue'

const originalPush = VueRouter.prototype.push;
 
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

//创建router实例对象，去管理一组一组的路由规则
const router = new VueRouter({
	routes:[
		{
			name:'index',
			path: '/',
			component:Index,
			redirect:'/Goods',
			children:[
				{
					name: 'Goods',
					path:'goods',
					component:Goods
				},
				{
					name: 'Comments',
					path:'comments',
					component:Comments
				},
				{
					name: 'Store',
					path:'store',
					component:Store
				}
			]
		},
		{
			name:'show',
			path: '/show',
			component:Show,
			
		}
	]
})

//暴露router
export default router